import fetch from 'node-fetch'

export const fetchurl = (url:string)=>{
  return fetch(url,{
    method:'GET',
    headers:{'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'},
    redirect:'manual'
  }).then(res=>res.text());
}
// fetchurl('http://xhslink.com/NpjOTr').then(content=>{
//   const reg =/<a.*?href="(.+)".*?>(.*?)<\/a>/ig
//   const arr = reg.exec(content);
//   const href = arr?.[1];
//   const url = new URL(href as string)
//   const str = url.pathname.split('/').pop()
//   console.log(str)
// })